package logic

import (
	"context"
	"regi-med/model/mysql"

	"regi-med/regirpc/internal/svc"
	"regi-med/regirpc/regirpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type RegiCreateLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewRegiCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegiCreateLogic {
	return &RegiCreateLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 添加
func (l *RegiCreateLogic) RegiCreate(in *regirpc.RegiCreateRequest) (*regirpc.RegiCreateResponse, error) {
	// todo: add your logic here and delete this line

	regi := mysql.Regi{
		Name:       in.Name,
		StatusCard: in.StatusCard,
		WeiXiName:  in.WeiXiName,
		Area:       in.Area,
		RegiCode:   in.RegiCode,
		CardCode:   in.CardCode,
		PhoneCode:  in.PhoneCode,
		Image:      in.Image,
		Ties:       in.Ties,
	}
	if err := regi.RegiCreate(mysql.DB); err != nil {
		return nil, err
	}

	return &regirpc.RegiCreateResponse{
		RegiId: int64(regi.ID),
	}, nil
}
